﻿using System;
using System.Data;
using System.Collections.Generic;
using CoreLab.Oracle; //using Devart.Data.Oracle; //using Oracle.DataAccess.Client;
using System.Web;
using System.Web.Caching;

using LMD.Constant;
using LMD.Lib.DataClass;
using LMD.Lib.Oracle;

namespace Cached
{
    /// <summary>
    /// Summary description for CustomerVisitTable
    /// </summary>
    public class CustomerVisitTable : CacheAbstraction
    {
        String sxFilterHierarki_Sales =
            @"
            v.SALES_EMPLOYEE_NO IN
            (
                select :prmID from dual
                UNION ALL
                select EMPLOYEE_NO from slogix.p_slx_usergroup_member where p_slx_usergroup_id IN
                (
                    select 
                        p_slx_usergroup_id 
                    from 
                        slogix.p_slx_usergroup
                    start with 
                        p_slx_usergroup_id =
                        (
                            select max(a)
                            from 
                            (
                                select 
                                    decode(ishead, 'Y', p_slx_usergroup_id, -1) a
                                from 
                                    slogix.p_slx_usergroup_member 
                                where EMPLOYEE_NO = :prmID
                            )
                        ) 
                    connect by prior 
                        p_slx_usergroup_id = parent_id
                )
            ) AND ";

        String sxFilterHierarki_CAR =
            @"
            v.CAR_EMPLOYEE_NO IN
            (  
                select :prmID from dual
                UNION ALL          
                select 
                    NIK 
                from 
                    v_icp_escalation
                /**/start with 
                    NIK = :prmID
                connect by prior 
                    t_qrtz_user_destination_id = parent_id
				-- EMERGENCY RELEASE FROM RDY
				-- ORACLE 11G DOESN'T SUPPORT CONNECT BY
				/*where nik = :prmID --'74940445'
                      and t_qrtz_user_destination_id in(
                            select v.t_qrtz_user_destination_id
                            from   v_icp_escalation v,
                                   sni.t_qrtz_user_destination w
                            where  (w.t_qrtz_user_destination_id = v.parent_id) 
							)*/
            ) AND ";
        public DataTable GetVisitList(String sxStatus, int iStartDate, int iEndDate, int iStartMonth, int iStartYear, int iEndMonth, int iEndYear)
        {
            return GetVisitList(sxStatus, iStartDate, iEndDate, iStartMonth, iStartYear, iEndMonth, iEndYear, false);
        }
        public DataTable GetVisitList(String sxStatus)
        {
            return GetVisitList(sxStatus, 0, 0, 0, 0, 0, 0, false);
        }
        public DataTable GetVisitList(String sxStatus, int iStartDate, int iEndDate, int iStartMonth, int iStartYear, int iEndMonth, int iEndYear, bool bForceRefresh)
        {
            String sxCacheKey = String.Format("{0}{1}_{2}_{3}{4}_{5}{6}_{7}{8}", KCache.T_CUSTOMER_VISIT, sxStatus, ICPUser.ID, 
                iStartDate.ToString(),
                iEndDate.ToString(),
                iStartMonth.ToString(),
                iStartYear.ToString(),
                iEndMonth.ToString(),
                iEndYear.ToString());

            if (bForceRefresh)
            {
                HttpRuntime.Cache.Remove(sxCacheKey);
            }
            if (HttpRuntime.Cache[sxCacheKey] == null)
            {
                DBLib dbl = new DBLib();
                OracleParameter prmStatus = new OracleParameter();
                List<OracleParameter> lsParams = new List<OracleParameter>();

                String sxExtraParam = String.Empty;

                //prmStatus.ParameterName = "prmStatus";
                //prmStatus.OracleDbType = OracleDbType.VarChar;
                //prmStatus.Value = sxStatus;
                lsParams.Clear();

                lsParams.Add(new OracleParameter());
                lsParams[lsParams.Count - 1].ParameterName = "prmStatus";
                lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
                lsParams[lsParams.Count - 1].Value = sxStatus;

                DataTable dt;

                //add param
                lsParams.Add(new OracleParameter());
                lsParams[lsParams.Count - 1].ParameterName = "prmStartDate";
                lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
                lsParams[lsParams.Count - 1].Value = iStartDate;
                lsParams.Add(new OracleParameter());
                lsParams[lsParams.Count - 1].ParameterName = "prmEndDate";
                lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
                lsParams[lsParams.Count - 1].Value = iEndDate;
                lsParams.Add(new OracleParameter());
                lsParams[lsParams.Count - 1].ParameterName = "prmStartMonth";
                lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
                lsParams[lsParams.Count - 1].Value = iStartMonth;
                lsParams.Add(new OracleParameter());
                lsParams[lsParams.Count - 1].ParameterName = "prmEndMonth";
                lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
                lsParams[lsParams.Count - 1].Value = iEndMonth;
                lsParams.Add(new OracleParameter());
                lsParams[lsParams.Count - 1].ParameterName = "prmStartYear";
                lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
                lsParams[lsParams.Count - 1].Value = iStartYear;
                lsParams.Add(new OracleParameter());
                lsParams[lsParams.Count - 1].ParameterName = "prmEndYear";
                lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
                lsParams[lsParams.Count - 1].Value = iEndYear;

                sxExtraParam +=
                    @"and 
                    (
                        trunc(v1.VISIT_DATETIME) >= to_date(:prmStartDate || '\' || :prmStartMonth || '\' || :prmStartYear, 'dd\mm\yyyy')
                        and trunc(v1.VISIT_DATETIME) <= to_date(:prmEndDate || '\' || :prmEndMonth || '\' || :prmEndYear, 'dd\mm\yyyy')
                    )";

                if (iStartDate == 1 && iEndDate == 1 && iStartMonth == 1 && iEndMonth == 1 && iStartYear == 1 && iEndYear == 1)
                {
                    sxExtraParam = "";
                    for (int i = 6; i >= 1; i--)
                    {
                        lsParams.RemoveAt(i);
                    }
                }
                if (ICPUser.IsAdmin || ICPUser.IsAdminForum)
                {
                    String sxQuery =
                    @"select
                        v1.T_CUSTOMER_VISIT_ID,
                        v1.VISIT_DATETIME,
                        v1.VISIT_STATUS,
                        v1.RESULT,
                        v1.FOLLOW_UP,
                        v1.CONTACT_PERSON_ID,
                        v1.NEW_CONTACT_PERSON_ID,
                        v1.CANCELATION_REASON,
                        v1.P_VISIT_PURPOSE_ID,
                        v1.VISIT_PURPOSE,
                        v1.P_CUSTOMER_EXPECTATION_ID,
                        v1.CUSTOMER_EXPECTATION,
                        v1.T_FILE_UPLOAD_ID,
                        v1.ORIGINAL_FILENAME,
                        v1.NAME,
                        v1.COMPANY_NAME,
                        v1.CUSTOMER_ID,
                        v2.EMPLOYEE_NO,
                        v2.EMPLOYEE_NAME CAR,
                        v1.CREATE_BY_NAME CREATED_BY
                    from
                        V_ICP_CUSTOMER_VISIT_LIST v1
                    left join
                        V_ICP_CAR v2
                    on
                        v1.CUSTOMER_ID = v2.COMPANY_ID
                    where
                        v1.VISIT_STATUS = :prmStatus and v2.EMPLOYEE_NAME is not null {0}
                    order by
                        v1.VISIT_DATETIME desc";

                    sxQuery = String.Format(sxQuery, sxExtraParam);
                    
                    dt = dbl.GetDataTable(sxQuery, lsParams.ToArray());
                }
                else
                {
                    //List<OracleParameter> lsParams = new List<OracleParameter>();
                    lsParams.Add(new OracleParameter());
                    lsParams[lsParams.Count - 1].ParameterName = "prmID";
                    lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
                    lsParams[lsParams.Count - 1].Value = ICPUser.ID;
                    //lsParams.Add(new OracleParameter());
                    //lsParams[lsParams.Count - 1].ParameterName = "prmStatus";
                    //lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
                    //lsParams[lsParams.Count - 1].Value = sxStatus;
                    String sxQuery =
                    @"
                    select
                        v1.T_CUSTOMER_VISIT_ID,
                        v1.VISIT_DATETIME,
                        v1.VISIT_STATUS,
                        v1.RESULT,
                        v1.FOLLOW_UP,
                        v1.CONTACT_PERSON_ID,
                        v1.NEW_CONTACT_PERSON_ID,
                        v1.CANCELATION_REASON,
                        v1.P_VISIT_PURPOSE_ID,
                        v1.VISIT_PURPOSE,
                        v1.P_CUSTOMER_EXPECTATION_ID,
                        v1.CUSTOMER_EXPECTATION,
                        v1.T_FILE_UPLOAD_ID,
                        v1.ORIGINAL_FILENAME,
                        v1.NAME,
                        v1.COMPANY_NAME,
                        v1.CUSTOMER_ID,
                        v2.EMPLOYEE_NO,
                        v2.EMPLOYEE_NAME CAR,
                        v1.CREATE_BY_NAME CREATED_BY
                    from
                        V_ICP_CUSTOMER_VISIT_LIST v1
                    left join
                        V_ICP_CAR v2
                    on
                        v1.CUSTOMER_ID = v2.COMPANY_ID
                    join
                        V_ICP_CUSTOMER_COMPLETE v
                    on
                        v1.CUSTOMER_ID = v.CUSTOMER_ID
                    where {0}
                        v1.VISIT_STATUS = :prmStatus
                    {1} order by
                        v1.VISIT_DATETIME desc";

                    if (ICPUser.RoleId == (int)ICPUserRole.CAR || ICPUser.RoleId == (int)ICPUserRole.CARAdminForum
                        || ICPUser.RoleId == (int)ICPUserRole.CARPimpinanCAR)
                    {
                        sxQuery = String.Format(sxQuery, sxFilterHierarki_CAR, sxExtraParam);
                    }
                    else if (ICPUser.RoleId == (int)ICPUserRole.Sales)
                    {
                        sxQuery = String.Format(sxQuery, sxFilterHierarki_Sales, sxExtraParam);
                    }
                    else
                    {
                        lsParams.RemoveAt(lsParams.Count - 1);
                        sxQuery = String.Format(sxQuery, String.Empty, sxExtraParam);
                    }
                    dt = dbl.GetDataTable(sxQuery, lsParams.ToArray());
                }
                AddToCache(sxCacheKey, dt, CacheType.FiveMinutes);
               
            }
            return (DataTable)HttpRuntime.Cache[sxCacheKey];
        }
        public DataTable GetVisitDetailById(int iCVID)
        {
            return GetVisitDetailById(iCVID, false);
        }
        public DataTable GetVisitDetailById(int iCVID, bool bForceRefresh)
        {
            String sxCacheKey = String.Format("{0}{1}", KCache.T_CUSTOMER_VISIT, iCVID.ToString());

            if (bForceRefresh)
            {
                HttpRuntime.Cache.Remove(sxCacheKey);
            }
            if (HttpRuntime.Cache[sxCacheKey] == null)
            {
                DBLib dbl = new DBLib();
                OracleParameter prmId = new OracleParameter();
                prmId.ParameterName = "prmId";
                prmId.OracleDbType = OracleDbType.Number;
                prmId.Value = iCVID;

                String sxQuery =
                @"
                select
                    v1.T_CUSTOMER_VISIT_ID,
                    v1.VISIT_DATETIME,
                    v1.VISIT_STATUS,
                    v1.RESULT,
                    v1.FOLLOW_UP,
                    v1.CONTACT_PERSON_ID,
                    v1.NEW_CONTACT_PERSON_ID,
                    v1.CANCELATION_REASON,
                    v1.P_VISIT_PURPOSE_ID,
                    v1.VISIT_PURPOSE,
                    v1.P_CUSTOMER_EXPECTATION_ID,
                    v1.CUSTOMER_EXPECTATION,
                    v1.T_FILE_UPLOAD_ID,
                    v1.ORIGINAL_FILENAME,
                    v1.NAME,
                    v1.COMPANY_NAME,
                    v1.CUSTOMER_ID,
                    v2.EMPLOYEE_NAME CAR,
                    v1.CREATE_BY_NAME
                from
                    V_ICP_CUSTOMER_VISIT_LIST v1
                left join
                    V_ICP_CAR v2
                on
                    v1.CUSTOMER_ID = v2.COMPANY_ID
                where
                    v1.T_CUSTOMER_VISIT_ID = :prmId";

                DataTable dt = dbl.GetDataTable(sxQuery, prmId);
                AddToCache(sxCacheKey, dt, CacheType.Daily);
                
            }
            return (DataTable)HttpRuntime.Cache[sxCacheKey];
        }
        public DataTable GetReminderList(bool bSeeAll)
        {
            return GetReminderList(bSeeAll, false);
        }
        public DataTable GetReminderList(bool bSeeAll, bool bForceRefresh)
        {
            String sxCacheKey = String.Empty;
            if (bSeeAll)
            {
                sxCacheKey = String.Format("{0}{1}", KCache.T_CUSTOMER_VISIT, "SeeAll");
            }
            else
            {
                sxCacheKey = String.Format("{0}{1}", KCache.T_CUSTOMER_VISIT, "NotSeeAll");
            }

            if (bForceRefresh)
            {
                HttpRuntime.Cache.Remove(sxCacheKey);
            }
            if (HttpRuntime.Cache[sxCacheKey] == null)
            {
                DBLib dbl = new DBLib();
                String sxFilter = String.Empty;
                if (!bSeeAll)
                {
                    sxFilter = "and ROWNUM < 6";
                }

                String sxQuery =
                @"
                select
                    T_CUSTOMER_VISIT_ID,
                    COMPANY_NAME,
                    NAME,
                    VISIT_DATETIME
                from
                    V_ICP_CUSTOMER_VISIT_LIST
                where
                    VISIT_STATUS = 'PLANNED'
                and
                    VISIT_DATETIME > sysdate
                and
                    VISIT_DATETIME < sysdate + 5"
                + sxFilter +
                @"order by
                    VISIT_DATETIME desc";

                DataTable dt = dbl.GetDataTable(sxQuery);
                AddToCache(sxCacheKey, dt, CacheType.Daily);
                
            }
            return (DataTable)HttpRuntime.Cache[sxCacheKey];
        }
        public DataTable GetVisitSummary(String sxCARId, int iStartDate,
            int iStartMonth, int iStartYear, int iEndDate, int iEndMonth, int iEndYear)
        {
            return GetVisitSummary(sxCARId, iStartDate, iStartMonth, iStartYear, iEndDate, iEndMonth, iEndYear, false);
        }
        public DataTable GetVisitSummary(String sxCARId, int iStartDate,
            int iStartMonth, int iStartYear, int iEndDate, int iEndMonth, int iEndYear, bool bForceRefresh)
        {
            String sxCacheKey = String.Format("{0}_{1}_{2}{3}_{4}{5}_{6}{7}",
                KCache.CV_SUM,
                sxCARId.ToString(),
                iStartDate.ToString(),
                iStartMonth.ToString(),
                iStartYear.ToString(),
                iEndDate.ToString(),
                iEndMonth.ToString(),
                iEndYear.ToString());

            if (bForceRefresh)
            {
                HttpRuntime.Cache.Remove(sxCacheKey);
            }

            if (HttpRuntime.Cache[sxCacheKey] == null)
            {
                DBLib dbl = new DBLib();
                String sxExtraParam = String.Empty;
                List<OracleParameter> lsParams = new List<OracleParameter>();
                if (!ICPUser.IsAdmin)
                {
                    if (!String.IsNullOrEmpty(sxCARId))
                    {
                        lsParams.Add(new OracleParameter());
                        lsParams[lsParams.Count - 1].ParameterName = "prmCARId";
                        lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
                        lsParams[lsParams.Count - 1].Value = sxCARId;
                    }
                    else
                    {
                        lsParams.Add(new OracleParameter());
                        lsParams[lsParams.Count - 1].ParameterName = "prmCARId";
                        lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
                        lsParams[lsParams.Count - 1].Value = ICPUser.ID;
                    }
                }
                else
                {
                    if (!String.IsNullOrEmpty(sxCARId))
                    {
                        lsParams.Add(new OracleParameter());
                        lsParams[lsParams.Count - 1].ParameterName = "prmCARId";
                        lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
                        lsParams[lsParams.Count - 1].Value = sxCARId;
                    }
                }

                if (lsParams.Count > 0)
                {
                    sxExtraParam =
                            @"and t1.CREATE_BY IN
                            (
                                select :prmCARId from dual
                                UNION ALL
								SELECT DISTINCT NIK
                                FROM 
                                v_icp_escalation
                                START WITH NIK = :prmCARId        
                                CONNECT BY PRIOR t_qrtz_user_destination_id = parent_id
                            )  
                            ";
                }

                lsParams.Add(new OracleParameter());
                lsParams[lsParams.Count - 1].ParameterName = "prmStartDate";
                lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
                lsParams[lsParams.Count - 1].Value = iStartDate;
                lsParams.Add(new OracleParameter());
                lsParams[lsParams.Count - 1].ParameterName = "prmStartMonth";
                lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
                lsParams[lsParams.Count - 1].Value = iStartMonth;
                lsParams.Add(new OracleParameter());
                lsParams[lsParams.Count - 1].ParameterName = "prmEndDate";
                lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
                lsParams[lsParams.Count - 1].Value = iEndDate;
                lsParams.Add(new OracleParameter());
                lsParams[lsParams.Count - 1].ParameterName = "prmEndMonth";
                lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
                lsParams[lsParams.Count - 1].Value = iEndMonth;
                lsParams.Add(new OracleParameter());
                lsParams[lsParams.Count - 1].ParameterName = "prmStartYear";
                lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
                lsParams[lsParams.Count - 1].Value = iStartYear;
                lsParams.Add(new OracleParameter());
                lsParams[lsParams.Count - 1].ParameterName = "prmEndYear";
                lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
                lsParams[lsParams.Count - 1].Value = iEndYear;

                String sxQuery = "";

                if (iStartDate == 1 && iStartMonth == 1 && iStartYear == 1 && iEndDate == 1 && iEndMonth == 1 && iEndYear == 1)
                {
                    int count = lsParams.Count;
                    if (count == 7)
                    {
                        for (int i = lsParams.Count - 1; i >= 1; i--)
                        {
                            lsParams.RemoveAt(i);
                        }
                    }
                    else
                    {
                        for (int i = lsParams.Count - 1; i >= 0; i--)
                        {
                            lsParams.RemoveAt(i);
                        }
                    }
                    //ubah View by Rista --> customer visit record
                    
                   /*sxQuery = String.Format(
                        @"select
                        COUNT(v1.T_CUSTOMER_VISIT_ID) TOTAL,
                        v2.EMPLOYEE_NAME CAR,
                        v1.company_name, 
                        V1.NAME CONTACT_PERSON, 
                        v1.customer_id, 
                        v1.create_by_name create_by
                    from
                        V_ICP_CUSTOMER_VISIT_LIST v1
                    left join
                        V_ICP_CAR v2
                    on
                        v1.CUSTOMER_ID = v2.COMPANY_ID
                    join
                        V_ICP_CUSTOMER_COMPLETE v
                    on
                        v1.CUSTOMER_ID = v.CUSTOMER_ID
                    where 
                        v1.VISIT_STATUS = 'REALIZED' and v2.EMPLOYEE_NAME is not null {0}
                        GROUP BY 
                        v2.EMPLOYEE_NAME, v1.company_name, V1.NAME, v1.customer_id, v1.create_by_name", sxExtraParam);*/ 
                }
                else
                {
                    //if (sxExtraParam.Trim() == "")
                    //{
                    //    sxExtraParam = "where ";
                    //}
                    //else
                    //{
                    //    sxExtraParam += "and ";
                    //}
                    //edited by Rista
                    sxExtraParam +=
                        @" 
                        and (
                            trunc(v1.VISIT_DATETIME) <= to_date(:prmEndDate || '\' || :prmEndMonth || '\' || :prmEndYear, 'dd\mm\yyyy')
                            and trunc(v1.VISIT_DATETIME) >= to_date(:prmStartdate || '\' || :prmStartMonth || '\' || :prmStartYear, 'dd\mm\yyyy')
                        )
                        ";

                    /*sxQuery = String.Format(
                    @"select
                    COUNT(v1.T_CUSTOMER_VISIT_ID) TOTAL,
                        v2.EMPLOYEE_NAME CAR, v1.company_name, V1.NAME CONTACT_PERSON, v1.customer_id, v1.create_by_name create_by
                    from
                        V_ICP_CUSTOMER_VISIT_LIST v1
                    left join
                        V_ICP_CAR v2
                    on
                        v1.CUSTOMER_ID = v2.COMPANY_ID
                    join
                        V_ICP_CUSTOMER_COMPLETE v
                    on
                        v1.CUSTOMER_ID = v.CUSTOMER_ID
                    where 
                        v1.VISIT_STATUS = 'REALIZED' and v2.EMPLOYEE_NAME is not null {0}
                        GROUP BY 
                        v2.EMPLOYEE_NAME, v1.company_name, V1.NAME, v1.customer_id, v1.create_by_name",
                     sxExtraParam);*/
                }

                if (ICPUser.IsAdmin)
                {
                    sxQuery = String.Format(@"select
                        count(v1.T_CUSTOMER_VISIT_ID) TOTAL,
                        v2.EMPLOYEE_NAME CAR,
                        v1.COMPANY_NAME,
                        v1.NAME CONTACT_PERSON, 
                        v1.customer_id, 
                        nvl(v1.create_by_name, '-') create_by
                    from
                        V_ICP_CUSTOMER_VISIT_LIST v1
                    left join
                        V_ICP_CAR v2
                    on
                        v1.CUSTOMER_ID = v2.COMPANY_ID
                    join 
                        t_customer_visit t1
                    on V1.T_CUSTOMER_VISIT_ID = T1.T_CUSTOMER_VISIT_ID
                    where
                        v1.VISIT_STATUS = 'REALIZED' and v2.EMPLOYEE_NAME is not null {0}
                        group by v2.EMPLOYEE_NAME,
                        v1.COMPANY_NAME,
                        v1.NAME, 
                        v1.customer_id, 
                        v1.create_by_name", sxExtraParam);
                }
                else
                {
                    sxQuery = String.Format(@"select
                        count(v1.T_CUSTOMER_VISIT_ID) TOTAL,
                        v2.EMPLOYEE_NAME CAR,
                        v1.COMPANY_NAME,
                        v1.NAME CONTACT_PERSON,
                        v1.CUSTOMER_ID,
                        nvl(v1.CREATE_BY_NAME, '-') CREATE_BY
                    from
                        V_ICP_CUSTOMER_VISIT_LIST v1
                    left join
                        V_ICP_CAR v2
                    on
                        v1.CUSTOMER_ID = v2.COMPANY_ID
                    join
                        V_ICP_CUSTOMER_COMPLETE v
                    on
                        v1.CUSTOMER_ID = v.CUSTOMER_ID
                    join 
                        t_customer_visit t1
                    on
                        V1.T_CUSTOMER_VISIT_ID = t1.T_CUSTOMER_VISIT_ID
                    where v1.VISIT_STATUS = 'REALIZED' {0}
                    group by v2.EMPLOYEE_NAME,
                        v1.COMPANY_NAME,
                        v1.NAME,
                        v1.CUSTOMER_ID,
                        v1.CREATE_BY_NAME", sxExtraParam); 
                }

                DataTable dt = dbl.GetDataTable(sxQuery, lsParams.ToArray());

                AddToCache(sxCacheKey, dt, CacheType.FiveMinutes);

            }
            return (DataTable)HttpRuntime.Cache[sxCacheKey];
        }
        public DataTable GetVisitList(int iStartDate, int iEndDate, int iStartMonth, int iStartYear, int iEndMonth, int iEndYear)
        {
            return GetVisitList("", iStartDate, iEndDate, iStartMonth, iStartYear, iEndMonth, iEndYear, false);
        }

        public override String GetCacheFilename()
        {
            return KCache.Filename.COSTUMER_VISIT;
        }
    }
}